<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>test</title>
    <style>
      body {
        display: flex;
        flex-direction: column;
      }
      .menu {
        width: 200px;
        min-height: 50px;
        margin: auto;
        background-color: chocolate;
        border-radius: 7px;
      }

      .item,
      .sub-item {
        text-align: center;
        line-height: 50px;
      }

      .sub-menu {
        height: 0;
        max-height: 1000vh;
        overflow: hidden;
      }

      .transition {
        transition: 0.3s;
      }
    </style>
  </head>
  <body>
    <div class="menu">
      <div class="item">item</div>
      <div class="sub-menu transition">
        <div class="sub-item">sub-item-1</div>
        <div class="sub-item">sub-item-2</div>
        <div class="sub-item">sub-item-3</div>
      </div>
    </div>
  </body>
  <script>
    const item = document.querySelector('.item')
    const subMenu = document.querySelector('.sub-menu')

    item.onclick = function () {
      if (!subMenu.style.height || subMenu.style.height === '0px') {
        subMenu.style.height = '150px'
      } else {
        subMenu.style.height = '0px'
      }
    }
  </script>
</html>
